﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />  
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
	  $("#b01").click(function(){
	  	var deviceId = document.getElementById("deviceIds").value;
			if(deviceId==null || deviceId=="" || deviceId.length!=20){
				alert("DEVICEID长度必须是20位");//1A32267BA0AB11221117
				return false;	
			}
			$.ajax({
	      type: "post",
	      url: "jsonPortal?deviceId="+deviceId+"&actionType=regDevice",
	      data: {},
	      dataType: "jsonp",
	      success: function (datas) {
	      		if(datas.portalResp.errcode==0){
	          	document.getElementById("myDiv").innerHTML = "<img src='"+datas.portalResp.qrcode+"'>";
	          }else if(datas.portalResp.errcode==1){
	          	document.getElementById("myDiv").innerHTML = "DEVICEID长度必须是20位";
	          }else if(datas.portalResp.errcode==100002){
	          	document.getElementById("myDiv").innerHTML = "该DEVICEID已经注册了";
	          }else if(datas.portalResp.errcode==2){
	          	document.getElementById("myDiv").innerHTML = "该DEVICEID未生效，请联系厂商。";
	          }
	      },
	      error: function (XMLHttpRequest, textStatus, errorThrown) {   
	      	alert(textStatus);      
	      }
	  	});
	  	
	  	
	  	
	  });
});

</script>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>结伴旅行设备注册</title>
<body>
<table width="95%" border="0" cellpadding="2" cellspacing="1">
<tr>
	<td width="200px" nowrap>请输入DEVICEID: <input type="text" name="deviceIds" id="deviceIds" value="1A32267BA0AB11221220" size="40"/></td>
</tr>	

<tr>
	<td width="200px" nowrap><button id="b01" type="button">提交</button></td>
</tr>	

</table>



<div id="myDiv"></div>

</body>
</html>